﻿using System;
using System.Collections.Generic;
using System.Text;
using Hkwl.WorldExpo.Merchant.Model;
using System.Collections;

namespace Hkwl.WorldExpo.Merchant.DataAccess.Impl.IBatisNet
{
    public class MerchantSqlMapDao : BaseSqlMapDao, IMerchantDao
    {

        #region NxMerchant 对象

        public NxMerchant GetNxMerchant(int merchantId)
        {
            return ExecuteQueryForObject<NxMerchant>("SelectNxMerchant", merchantId);
        }

        public bool InsertNxMerchant(NxMerchant merchant)
        {
            object obj = ExecuteInsert("InsertNxMerchant", merchant);
            if ((int)obj > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool UpdateNxMerchant(NxMerchant merchant)
        {
            int ret = ExecuteUpdate("UpdateNxMerchant", merchant);
            if (ret > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public NxMerchant CheckMerchantLogin(string loginName, string password)
        {
            Hashtable ht = new Hashtable();
            ht["LoginName"] = loginName;
            ht["Password"] = password;

            return ExecuteQueryForObject<NxMerchant>("CheckMerchantLogin", ht);
        }

        public IList<NxMerchant> GetNxMerchantCollection(int status, int pageIndex, int pageSize, ref int count)
        {
            Hashtable ht = new Hashtable();
            ht["Status"] = status;

            count = ExecuteQueryForObject<int>("GetMerchantCount", ht);
            return ExecuteQueryForList<NxMerchant>("GetMerchantCollection", ht, (pageIndex - 1) * pageSize, pageSize);
        }

        #endregion

        #region NxShopType 对象

        public IList<NxShopType> GetShopTypeCollection()
        {
            return ExecuteQueryForList<NxShopType>("SelectNxShopType", null);
        }

        public bool InsertNxShopType(NxShopType shopType)
        {
           object obj= ExecuteInsert("InsertNxShopType", shopType);
           if ((int)obj > 0)
           {
               return true;
           }
           else
           {
               return false;
           }
        }

        #endregion

        #region NxMerchantLog 对象

        public bool InsertNxMerchantLog(NxMerchantLog log)
        {
            object obj = ExecuteInsert("InsertNxMerchantLog", log);
            if ((int)obj > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public NxMerchantLog GetNxMerchantLogById(NxMerchantLog logId)
        {
            return ExecuteQueryForObject<NxMerchantLog>("SelectNxMerchantLog", logId);
        }

        public IList<NxMerchantLog> GetNxMerchantLogCollection(int merchantId, int shopTypeId, int pageIndex, int pageSize, ref int count)
        {
            Hashtable ht = new Hashtable();
            ht["MerchantId"] = merchantId;
            ht["ShopTypeId"] = shopTypeId;

            count = ExecuteQueryForObject<int>("GetMerchantLogCount", ht);
            return ExecuteQueryForList<NxMerchantLog>("GetMerchantLogCollection", ht, (pageIndex - 1) * pageSize, pageSize);
        }

        #endregion
    }
}
